package meijuli.com.join51.business.utils;

import android.view.View;

/**
 * 防止重复点击
 *
 * @author Jack 2018-01-29 18:52
 */
public abstract class DoubleClick implements View.OnClickListener {
    /**
     * 这里设置不能超过多长时间
     */
    public static final int MIN_CLICK_DELAY_TIME = 1000;
    private long lastClickTime = 0;

    /**
     * 点击事件
     * @param v
     */
    protected abstract void onNoDoubleClick(View v);

    @Override
    public void onClick(View v) {
        long currentTime = System.currentTimeMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoDoubleClick(v);
        }
    }
}
